package final2107.day13.jdkproxy;

import java.lang.reflect.Proxy;

public class JDKProxyFactory {
    public static void main(String[] args) {
        //目标对象
        UserOperation userOperation = new UserOperationImpl();
        //切面类对象
        TimeAspect timeAspect = new TimeAspect(userOperation);
        //使用jdk的api方法将二者组合产生代理对象
        UserOperation proxy = (UserOperation) Proxy.newProxyInstance(
                userOperation.getClass().getClassLoader(),
                userOperation.getClass().getInterfaces(),
                timeAspect
        );
        System.out.println(proxy.getClass());
        //调用代理对象中的业务方法，执行的就是组合后的代码
        String message = proxy.login("tom","123");
        System.out.println(message);
//        System.out.println(proxy);
    }
}
